package love.yuanmengrobot.guoyitanghoutai.util;


import love.yuanmengrobot.guoyitanghoutai.dto.UserSessionDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;



@Component
public class UsernameUtil {
    @Resource
    private HttpServletRequest request;
    @Autowired
    UsernameUtil usernameUtil;

    public String getOperateUser(){
        UserSessionDto user = (UserSessionDto) request.getSession().getAttribute("user");
        return user==null ? null: user.getUsername();
    }
    public String getOrgCode(){
        UserSessionDto user = (UserSessionDto) request.getSession().getAttribute("user");
        return user==null ? null: user.getOrgCode();
    }

    public String getRoleName(){
        UserSessionDto user = (UserSessionDto) request.getSession().getAttribute("user");
        return user==null ? null: user.getRolename();
    }

    public String getItemCode() {
        UserSessionDto user = (UserSessionDto) request.getSession().getAttribute("user");
        return user==null ? null: user.getItemcode();
    }

    public String getCityId() {
        UserSessionDto user = (UserSessionDto) request.getSession().getAttribute("user");
        return user==null ? null: user.getCityId();
    }
}
